<template>
	<view>
		<view class="companyInfo">
			<!-- <view>
				管理员：{{manager_id}}
			</view> -->
			<view>
				<view class="hvl-txt-link" @click="goindex">返回首页</view>
			</view>
			<view>
				<view class="hvl-txt-link" @click="totemperature">查看登记信息</view>
			</view>
		</view>
		<view class="uni-padding-wrap">
			<view class="uni-flex uni-column table-content">
				<view class="uni-flex uni-row table-header">
					<view class="flex-item table-column" style="width: 20%;">姓名</view>
					<view class="flex-item table-column" style="width: 20%;">温度</view>
					<view class="flex-item table-column" style="width: 20%;">交通方式</view>
					<view class="flex-item table-column" style="width: 40%;">登记时间</view>
				</view>
				<view ref='_list' class="flex-item flex-item-V" v-for="(list, index) in lists" v-bind:key="index">

					<view class="uni-flex uni-row table-body">
						<view class="flex-item table-column hvl-txt-link" style="width: 20%;" @click="goDetail(list)">{{list.xinmin}}</view>
						<view class="flex-item table-column" style="width: 20%;">{{list.Temperature}}</view>
						<view class="flex-item table-column" style="width: 20%;">{{list.Traffic}}</view>
						<view class="flex-item table-column" style="width: 40%;">{{list.create_date}}</view>
						
					</view>
				</view>
				<view v-if="list.length === 0" class="table-body" style="text-align: center;">
					暂无数据
				</view>
			</view>
			<view class="pageList">
				<uni-pagination :total="totalRow" :current="page" :pageSize="size" @change="changePage"></uni-pagination>
			</view>
			<view class="pageDesc">总共{{totalRow}}条</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="popupCon">
				<view></view>
				<view>登记时间：{{currItem.create_date}}</view>
				<view>姓名：{{currItem.xinmin}}</view>
				<view>交通方式：{{currItem.Traffic}}</view>
				<view>拜访对象：{{currItem.visitor_for}}</view>
				<view>联系方式：{{currItem.visitor_for_mobile}}</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {pageTemperature} from '../../../api/index.js';
	import uniPagination from '@dcloudio/uni-ui/lib/uni-pagination/uni-pagination.vue';
	import uniPopup from "@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue";
	import { xlsxUtil } from '../../../common/xlsxUtil.js'
	import { excelConfig } from '../../../common/hvl-excel-config.js'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import moment from 'moment';
	export default {
		components: {
			uniPagination,
			uniPopup
		},
		data() {
			return {
				manager_id:wx.getStorageSync("SysId"),
				lists:[],
				total: 0,
				page: 1,
				size: 15,
				totalRow:'',
				totalPage:'1',
				formData: {},
				json_data: [],
				currItem: {},
				excelConf:excelConfig
			}
		},
		onLoad: function(option) {
			console.log(option.p);
			this.page = option.p || 1;
		},
		computed: mapState(['hasLogin', 'userInfo']),
		methods: {
			totemperature: function() {
				uni.navigateTo({
					url: './enterprise'
				});
			},
			// ...mapMutations(['logout']),
			goindex: function() {
				uni.navigateTo({
					url: '../../index/index'
				});
			},
			getExcelData:function(excelObj) {
				xlsxUtil.init(excelObj.funcName, {}, excelObj.showFields, 'downlink', excelObj.downloadName);
				xlsxUtil.getExcelData();
			},
			load(){
				var datelist={
					page_number:'1',
					page_size:'15',
					company_id:wx.getStorageSync("manage_company_id")
				}
				var _datelist=pageTemperature(datelist)
				Promise.resolve(_datelist).then(function (result) { 
					if(result.code=='0'){
						wx.setStorageSync('listdata2',result.data)
					}
					 })
						 var _list =wx.getStorageSync('listdata2')
						 this.lists =_list.list
						 console.log(this.lists)
					 this.list =aaa;
				if (this.hasLogin) {if (this.userInfo.super == 1) {
						this.formData = {
							page: this.page,
							size: this.size,
							company:this.company
						};
						this.get();
					} else {
						uni.navigateTo({
							url: '../stat/stat'
						});
					}
				} else {
					this.quitLogin();
				}
				console.log(wx.getStorageSync('listdata2'))
			},
			goDetail: function(d) {
				this.currItem = d;
				this.$refs.popup.open();
			},
			changePage: function(e) {
				this.page = e.current;
				console.log(this.page)
				this.formData.page = e.current;
				this.get(this.page);
			},
			get(index) {
				var that =this
				var datelist={
					page_number:index,
					page_size:'15',
					company_id:this.manager_id
				}
				var datelist=pageTemperature(datelist)
				Promise.resolve(datelist).then(function(result) {
					if (result.code == '0') {
						wx.setStorageSync('listdata2', result.data)
						that.lists = result.data.list
						that.totalPage =result.data.totalPage
						that.totalRow =result.data.totalRow
					}
				})
			}
		},
		mounted() {
			if(wx.getStorageSync("manage_company_id") !=''){
				this.manager_id =wx.getStorageSync("manage_company_id")
				}
				if(wx.getStorageSync("SysId") != ''){
					this.manager_id =wx.getStorageSync("SysId")
				}
				
			var that =this
			var datelist={
				page_number:'1',
				page_size:'15',
				company_id:this.manager_id
			}
			var datelist=pageTemperature(datelist)
			Promise.resolve(datelist).then(function(result) {
				if (result.code == '0') {
					wx.setStorageSync('listdata2', result.data)
					that.lists = result.data.list
					that.totalPage =result.data.totalPage
					that.totalRow =result.data.totalRow
				}
			})
				
		}
	}
</script>

<style>
	.companyInfo {
		margin-top: 20rpx;
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
	}
	.popupCon {
		background-color: #FFFFFF;
		padding: 30rpx 40rpx;
	},

	.uni-form-item .title {
		padding: 14rpx 0;
		width: 180rpx;
		text-align: right;
		background-color: #FFFFFF;
	}

	.table-content {
		padding: 10rpx 0;
	}

	.table-column {
		text-align: center;
		line-height: 40rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.table-header {
		justify-content: space-between;
		color: #909399;
		background-color: #FFFFFF;
		border-top: 1px solid #ebeef5;
		border-bottom: 1px solid #ebeef5;
		padding: 18rpx 0;
	}

	.table-body {
		justify-content: space-between;
		background-color: #FFFFFF;
		border-bottom: 1px solid #ebeef5;
		padding: 10rpx 0;
		color: #888888;
	}

	.pageList {
		background-color: #FFFFFF;
		margin-top: 20rpx;

	}

	.pageDesc {
		text-align: center;
		margin-top: 10rpx;
		margin-bottom: 40rpx;
		font-size: 14px;
	}
</style>
